﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Projeto_Gilberto
{
    public partial class Calendário : Form
    {
        Main main;
        DateTime endD;
        public String year
        {
            get { return Year.Text; }
            set { Year.Text = value; }
        }
        public String month
        {
            get { return Month.Text; }
            set { Month.Text = value; }
        }
        public String dateEndStr
        {
            get { return DateField.Text; }
            set { DateField.Text = value; }
        }

        public Calendário(Main mn)
        {
            InitializeComponent();
            main = mn;
            //DateField.Text = main.Item_field.Text.ToString();            
        }
        private void Calendario_DateChanged(object sender, DateRangeEventArgs e)
        {
            endD = Calendario.SelectionEnd;
            dateEndStr = endD.Date.ToShortDateString();
            month = (endD.Month < 10) ? "0" + endD.Month : "" + endD.Month;
            DateField.Text = dateEndStr;    
            Month.Text = month;
            Year.Text = endD.Year.ToString();
        }
        private void Calendário_Load(object sender, EventArgs e)
        {
            endD = Calendario.SelectionEnd;
            dateEndStr = endD.Date.ToShortDateString();
            month = (endD.Month < 10) ? "0" + endD.Month : "" + endD.Month;
            DateField.Text = dateEndStr;
            Month.Text = month;
            Year.Text = endD.Year.ToString();
        }
        public void button1_Click(object sender, EventArgs e)
        {
            main.Data_field.Text = DateField.Text;
            main.Data_field.Refresh();
            main.Ano.Text = year;

            #region Meses
            switch (month)
            {
                case "01":
                    main.Mes.Text = "Janeiro";
                    break;
                case "02":
                    main.Mes.Text = "Fevereiro";
                    break;
                case "03":
                    main.Mes.Text = "Março";
                    break;
                case "04":
                    main.Mes.Text = "Abril";
                    break;
                case "05":
                    main.Mes.Text = "Maio";
                    break;
                case "06":
                    main.Mes.Text = "Junho";
                    break;
                case "07":
                    main.Mes.Text = "Julho";
                    break;
                case "08":
                    main.Mes.Text = "Agosto";
                    break;
                case "09":
                    main.Mes.Text = "Setembro";
                    break;
                case "10":
                    main.Mes.Text = "Outubro";
                    break;
                case "11":
                    main.Mes.Text = "Novembro";
                    break;
                case "12":
                    main.Mes.Text = "Dezembro";
                    break;
            }
            #endregion

            this.Close();
        }                
    }
}
